#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QMessageBox>
MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_pushButton_clicked()
{
    QMessageBox* messageBox = new QMessageBox();
    messageBox->setWindowTitle("对话框窗口图标");
    messageBox->setText("这是对话框的文本");
    messageBox->setIcon(QMessageBox::Warning);
//    messageBox->setStandardButtons(QMessageBox::Ok | QMessageBox::Save | QMessageBox::Cancel);
    QPushButton* button = new QPushButton("按钮");
    messageBox->addButton(button, QMessageBox::AcceptRole);

//    messageBox->show();
    messageBox->exec();

    messageBox->setAttribute(Qt::WA_DeleteOnClose);
}
